package cn.com.nes.common.em.platform;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 系统分类枚举
 */
public enum PlatformEnum {

    _agent("nes-agent", "热链云", "AgentPlatform", "agent"),
    _call("nes-call", "长效管护", "nes-call-center", "call"),
    _ope("nes-ope", "运营", "nes-operation-platform", "ope"),
    _clean("nes-clean", "清洁取暖", "", ""),
    _easy_repair("easy-repair", "易修", "easy-repair", "er"),
    _repair("nes-repair", "和美乡村用户端", "WxServiceRepair", "repair"),
    _village("nes-village-pc", "和美乡村平台", "nes-village", "village"),
    _message("nes-message", "消息中心", "nes-message", "message"),

    ;

    private String code;

    private String name;

    private String serverContext;

    private String sjly;

    PlatformEnum(String code, String name, String serverContext, String sjly) {
        this.code = code;
        this.name = name;
        this.serverContext = serverContext;
        this.sjly = sjly;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getServerContext() {
        return serverContext;
    }

    public String getSjly() {
        return sjly;
    }

    public static PlatformEnum getEnum(String key) {
        Map<String, PlatformEnum> map = new HashMap<>();
        for (PlatformEnum platformEnum : values()) {
            map.put(platformEnum.getCode(), platformEnum);
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的平台类型");
        }
        return map.get(String.valueOf(key));
    }
}
